package com.blustreaksw.cyclecoach.util;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

/***********************************************************************
 * Helper class to simply creation of simple Notification popup dialog.
 * 
 * @author Tomas Rivera
 *
 ***********************************************************************/
public class NotificationDialogFragment extends DialogFragment {
	
	private String mDialogTitle;
	private String mDialogMessage;
	private DialogInterface.OnClickListener mListener;
	private Context mContext;
	
	public NotificationDialogFragment() {}
	
	/********************************************************************************
	 * Configures dialog fragment that was created with default constructor.
	 * 
	 * @param	okListener
	 * 		DialogInterface.OnClickListener that handles when user clicks "Dismiss"
	 * @param	title
	 * 		String that is displayed on the title bar of the dialog.
	 * @param	message
	 * 		String that appears in the dialog message box.
	 * @param	context
	 * 		Application context that the caller belongs to.
	 * @return	ConfirmationDialogFragment object
	 ********************************************************************************/
	public NotificationDialogFragment configureDialog(
			DialogInterface.OnClickListener clickListener,
			String title, String message, Context context) {
		mDialogMessage = message;
		mDialogTitle = title;
		mListener = clickListener;
		mContext = context;
		return this;
	}
	
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
		builder.setTitle(mDialogTitle)
			.setMessage(mDialogMessage)
			.setNeutralButton("Dismiss", mListener);
		return builder.create();
	}

}
